#if !defined(AFX_USBPHONECTRLCTL_H__256A1EAC_3884_4177_B78B_818025895961__INCLUDED_)
#define AFX_USBPHONECTRLCTL_H__256A1EAC_3884_4177_B78B_818025895961__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "MciPlayer.h"

// UsbPhoneCtrlCtl.h : Declaration of the CUsbPhoneCtrlCtrl ActiveX Control class.

/////////////////////////////////////////////////////////////////////////////
// CUsbPhoneCtrlCtrl : See UsbPhoneCtrlCtl.cpp for implementation.

class CUsbPhoneCtrlCtrl : public COleControl
{
	DECLARE_DYNCREATE(CUsbPhoneCtrlCtrl)

// Constructor
public:
	CUsbPhoneCtrlCtrl();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CUsbPhoneCtrlCtrl)
	public:
	virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
	virtual void DoPropExchange(CPropExchange* pPX);
	virtual void OnResetState();
	virtual DWORD GetControlFlags();
	//}}AFX_VIRTUAL

// Implementation
protected:
	afx_msg LONG OnUsbEvent(WPARAM wParam, LPARAM lParam);
	~CUsbPhoneCtrlCtrl();

	DECLARE_OLECREATE_EX(CUsbPhoneCtrlCtrl)    // Class factory and guid
	DECLARE_OLETYPELIB(CUsbPhoneCtrlCtrl)      // GetTypeInfo
	DECLARE_PROPPAGEIDS(CUsbPhoneCtrlCtrl)     // Property page IDs
	DECLARE_OLECTLTYPE(CUsbPhoneCtrlCtrl)		// Type name and misc status

// Message maps
	//{{AFX_MSG(CUsbPhoneCtrlCtrl)
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnDestroy();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

// Dispatch maps
	//{{AFX_DISPATCH(CUsbPhoneCtrlCtrl)
	long m_enableWatchDog;
	afx_msg void OnEnableWatchDogChanged();
	short m_usbPlugStatus;
	afx_msg void OnUsbPlugStatusChanged();
	afx_msg long InitPhoneDevice();
	afx_msg long StopAudioPlay();
	afx_msg void StopAudioRecord();
	afx_msg long DialNumber(LPCTSTR szDialNumber, long DialLength);
	afx_msg BSTR GetKeyCodeString(short KeyCode, short Language);
	afx_msg BSTR GetStatusString(long Status, long Language);
	afx_msg long SendUsbphoneCommand(short CommandID, short BufferLength, LPUNKNOWN CommandBuffer);
	afx_msg void HandFreeOn();
	afx_msg void HandFreeOff();
	afx_msg short GetUsbPhoneHwVersion();
	afx_msg void VoipOn();
	afx_msg void VoipOff();
	afx_msg void PcRingToneOn();
	afx_msg void PcRingToneOff();
	afx_msg short GetPhoneStatus();
	afx_msg void LineBusyDetect();
	afx_msg void UsbSpeakerPlayOn();
	afx_msg void UsbSpeakerPlayOff();
	afx_msg void UsbAudioPlayToLine();
	afx_msg void UsbAudioStopToLine();
	afx_msg void RecordFromMicOn();
	afx_msg void RecordFromMicOff();
	afx_msg void SetDtmfTiming(short Timing);
	afx_msg void PhoneRFunction(short OffTiming);
	afx_msg long RecordFromLine(short isStartPaseStop, LPCTSTR RecordFileName);
	afx_msg long RecordFromMic(short StartPauseStop, LPCTSTR RecordFileName);
	afx_msg long PlayToLine(short StartPauseStop, LPCTSTR PlayFileName, long Pos);
	afx_msg long PlayToSpeker(short PlayPauseStop, LPCTSTR PlayFileName, long Pos);
	afx_msg void RecordFromLineOn();
	afx_msg void RecordFromLineOff();
	afx_msg void DirectDialout(LPCTSTR szDialNumber);
	afx_msg long DeInitPhone();
	//}}AFX_DISPATCH
	DECLARE_DISPATCH_MAP()

	afx_msg void AboutBox();

// Event maps
	//{{AFX_EVENT(CUsbPhoneCtrlCtrl)
	void FireUsbPhoneEvent(long Event, long Param)
		{FireEvent(eventidUsbPhoneEvent,EVENT_PARAM(VTS_I4  VTS_I4), Event, Param);}
	void FireUsbPlug(BOOL IsPlugIn)
		{FireEvent(eventidUsbPlug,EVENT_PARAM(VTS_BOOL), IsPlugIn);}
	void FireUsbPhoneKeyPress(short Key)
		{FireEvent(eventidUsbPhoneKeyPress,EVENT_PARAM(VTS_I2), Key);}
	void FireOnRing()
		{FireEvent(eventidOnRing,EVENT_PARAM(VTS_NONE));}
	void FireOnComingCall(DATE date, LPCTSTR CallNumber, LPCTSTR CallName)
		{FireEvent(eventidOnComingCall,EVENT_PARAM(VTS_DATE  VTS_BSTR  VTS_BSTR), date, CallNumber, CallName);}
	//}}AFX_EVENT
	DECLARE_EVENT_MAP()

// Dispatch and event IDs
public:
	INT m_DialState;
    BYTE m_szDialNumber[64];
	enum {
	//{{AFX_DISP_ID(CUsbPhoneCtrlCtrl)
	dispidEnableWatchDog = 1L,
	dispidUsbPlugStatus = 2L,
	dispidInitPhoneDevice = 3L,
	dispidStopAudioPlay = 4L,
	dispidStopAudioRecord = 5L,
	dispidDialNumber = 6L,
	dispidGetKeyCodeString = 7L,
	dispidGetStatusString = 8L,
	dispidSendUsbphoneCommand = 9L,
	dispidHandFreeOn = 10L,
	dispidHandFreeOff = 11L,
	dispidGetUsbPhoneHwVersion = 12L,
	dispidVoipOn = 13L,
	dispidVoipOff = 14L,
	dispidPcRingToneOn = 15L,
	dispidPcRingToneOff = 16L,
	dispidGetPhoneStatus = 17L,
	dispidLineBusyDetect = 18L,
	dispidUsbAudioPlayOn = 19L,
	dispidUsbAudioPlayOff = 20L,
	dispidUsbAudioPlayToLine = 21L,
	dispidUsbAudioStopToLine = 22L,
	dispidPcRecordOn = 23L,
	dispidPcRecordOff = 24L,
	dispidSetDtmfTiming = 25L,
	dispidPhoneRFunction = 26L,
	dispidRecordFromLine = 27L,
	dispidRecordFromMic = 28L,
	dispidPlayToLine = 29L,
	dispidPlayToSpeker = 30L,
	dispidRecordFromLineOn = 31L,
	dispidRecordFromLineOff = 32L,
	dispidDirectDialout = 33L,
	dispidDeInitPhone = 34L,
	eventidUsbPhoneEvent = 1L,
	eventidUsbPlug = 2L,
	eventidUsbPhoneKeyPress = 3L,
	eventidOnRing = 4L,
	eventidOnComingCall = 5L,
	//}}AFX_DISP_ID
	};
private:
    CMciPlayer m_oMci;
	BOOL CtrlSendCmd(BYTE bCmdID,BYTE bInputBufferLen = 0,void * pInPutBuffer = NULL);
	LONG OnCallIn(LPARAM param);
	LONG OnUsbPnpMsg(LPARAM status);
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_USBPHONECTRLCTL_H__256A1EAC_3884_4177_B78B_818025895961__INCLUDED)
